/******************************************************************************
 cnome: A C++ source "genes" discover. :-)

 See more details at:

   http://www.codeplex.com/cnome

 The original author site is at: http://www.alexandre-barbosa.com/

 Copyright (c) 2008 Alexandre Barbosa.
 Distributed under the MIT License. (See accompanying file LICENSE-MIT.txt 
 or at http://www.codeplex.com/cnome/license)
 ******************************************************************************/

#ifndef DIRECTIVE_RP_H
#define DIRECTIVE_RP_H

#include "directive_base.h"
#include "variables.h"

namespace cnome { namespace directive {

    struct rp_parser_gen;

    template <typename ParserT>
    struct rp
    :   public boost::spirit::classic::unary<ParserT, boost::spirit::classic::parser<rp<ParserT> > > 
    {
        typedef rp<ParserT>                     self_t;
        typedef boost::spirit::classic::unary_parser_category           parser_category_t;
		typedef rp_parser_gen                   parser_generator_t;
        typedef boost::spirit::classic::unary<ParserT, boost::spirit::classic::parser<self_t> > base_t;

		rp(ParserT const& p)
        : base_t(p) {}

		const char* MyName() const { return "rp"; }

		template <typename ScannerT>
        inline void
        deriv_action_before_parse(
            ScannerT const& scan)
		{
			var::l_prmVars.push_back(var::prmVars);
		}

		template <typename ScannerT>
        inline void
        deriv_action_after_parse(
            ScannerT const& scan) 
		{
			var::prmVars=var::l_prmVars.back();
			var::l_prmVars.pop_back();
		}
    };

	//////////////////////////////////
    const drt_parser_gen<rp> remain_prm_d = drt_parser_gen<rp>();

}} // namespace cnome { namespace directive {

#endif  // DIRECTIVE_RP_H
